<template>
    <!-- 顶部 -->
    <div class="main">
      <!-- 左 -->
      <div class="letf">
        <div class="letf-one">
          <img class="letf_one1" src="@/assets/logo.png" alt="健康有道" ></img>
          <div class="letf_one2">健康有道</div>
        </div>
        <div class="letf-two">
          <ul v-for="(item, index) in props.menu" >
            <li :style="{
                fontSize: selectedIndex === index ? '18px' : '14px',
                color: selectedIndex === index ? '#1c1c1c' : 'rgb(102 102 102)'
            }"  @click="toggleSize(`${item.path}`,index)" > {{ item.name }}</li>
          </ul>
          <!-- <div style="margin-left: 8px;" :style="{ fontSize: selectedIndex === 0 ? '18px' : '14px' }" @click="toggleSize(0)">健康咨询</div>
          <div style="margin-left: 8px;" :style="{ fontSize: selectedIndex === 1 ? '18px' : '14px' }" @click="toggleSize(1)">我的收藏</div>
          <div style="margin-left: 8px;" :style="{ fontSize: selectedIndex === 2 ? '18px' : '14px' }" @click="toggleSize(2)">我的收藏</div> -->
        </div>
      </div>
      <!-- 中 -->
      <div class="centre">
        <input class="search-input"  type="text" placeholder="搜索..." autofocus />
        <button class="search-button customer">搜索</button>
      </div>
      <!-- 右 -->
      <div class="right">
        <div class=" a right_one">指标记录</div>
        <div class="a right_two">消息</div>
        <div class=" right_three">
          <el-dropdown placement="bottom-end" >
          <span class="dropdown"  style="outline: none;">
            <el-avatar style="margin-right: 10px;" />
            111
            <el-icon><CaretBottom /></el-icon>
          </span>
          <template #dropdown >
            <el-dropdown-menu >
              <el-dropdown-item icon="User" command="user">个人中心</el-dropdown-item>
              <el-dropdown-item icon="SwitchButton" command="logout">退出登录</el-dropdown-item>
            </el-dropdown-menu>
          </template>
        </el-dropdown>
        </div>
      </div>
    </div>
  </template>
  
  <script setup>
  import { ref } from 'vue';
  import { defineProps } from 'vue';
  import { useRoute,useRouter } from 'vue-router';
  const route = useRoute();
  const router = useRouter();
  // 使用 ref 定义响应式数据
  const selectedIndex = ref(0);
  const isClicked = ref([false, false, false]);
  let props = defineProps(['menu'])
  // 方法定义
  function toggleSize(path,index) {
    // selectedIndex.value = a;
    // isClicked.value = isClicked.value.map((clicked, index) => index === a ? true : false);
    selectedIndex.value = index;
    router.push({ path });
  }
  </script>
  
  <style lang="scss" scoped>
  ul, li {
    margin: 0; /* 移除外边距 */
    padding: 0; /* 移除内边距 */
    list-style: none; /* 移除列表项前的标记（如圆点） */
}
  .main {
    width: 1200px;
    height: 70px;
    margin: auto;
    line-height: 70px;
    border-bottom: 1px solid #ccc;
    display: flex;
  }
  // 左
  .letf {
    display: flex;
    .letf-one {
      display: flex;
      align-items: center;
      .letf_one1 {
        width: 30px;
        height: 30px;
        display: block;
      }
      .letf_one2{
        margin-left: 8px;
        font-size: 20px;
        font-weight: bold;
      }
    }
    .letf-two{
      display: flex;
      ul{
        margin-left: 15px;
      }
    }
  }
  // 中
  .centre {
  margin: auto;
  border: 1px solid #ccc;
  border-radius: 10px;
  height: 40px;
  line-height: 40px;
  overflow: hidden;
  display: flex;
  .search-input {
    display: flex;
    margin-left: 15px;
    height: 40px;
  line-height: 40px;
    border: none;
    outline: none;
    font-size: 16px;
    width: 200px;
    
  }
  .search-button {
    display: flex;
    border: none;
    padding: 5px 15px; /* 添加内边距以创建空隙和按钮内部空间 */
    margin-right: 10px; /* 右侧外边距 */
    background-color: #000;
    color: #fff;
    font-size: 12px;
    border-radius: 10px; /* 保持与容器相同的圆角 */
    height: 30px;
    margin: 5px;
  }
  }
  // 右
  .right {
    height: 70px;
    display: flex;
    align-items: center; /* 添加这个属性来垂直居中 */
    .a{
      margin-right: 10px;
    }
    .dropdown {
    height: 70px;
    display: flex;
    align-items: center; /* 添加这个属性来垂直居中 */
  }
  }
  </style>
  